Page({
    data: {
        slideButtons: [{
                type: "warn",
                text: "删除",
                extClass: "test1",
                src: '/images/add.svg'
            },
            {
                type: "primary",
                text: "条件1",
                extClass: "test1",
                src: '/images/cell.svg'
            },
            {
                type: "primary",
                text: "条件2",
                extClass: "test1",
                src: '/images/setting.svg'
            },
        ],

        checkboxItems: [
            { name: "standard is dealt for u.", value: "0", checked: true },
            { name: "standard is dealicient for u.", value: "1" },
        ],
        radioItems: [
            { name: "cell standard", value: "0" },
            { name: "cell standard", value: "1", checked: true },
        ],
    },

    slideButtonTap: function(e) {
        console.log(e.detail.index);

    },

    radioChange: function(e) {
        console.log("radio发生了change事件, 携带value值为:", e.detail.value);

        var radioItems = this.data.radioItems;
        for (var i = 0, len = radioItems.length; i < len; ++i) {
            radioItems[i].checked = radioItems[i].value == e.detail.value;
        }

        this.setData({
            radioItems: radioItems,
            ["formData.radio"]: e.detail.value,
        });
    },

    checkboxChange: function(e) {
        console.log("checkbox发生change事件, 携带value值为:", e.detail.value);

        var checkboxItems = this.data.checkboxItems,
            values = e.detail.value;
        for (var i = 0, lenI = checkboxItems.length; i < lenI; ++i) {
            checkboxItems[i].checked = false;

            for (var j = 0, lenJ = values.length; j < lenJ; ++j) {
                if (checkboxItems[i].value == values[j]) {
                    checkboxItems[i].checked = true;
                    break;
                }
            }
        }
        this.setData({
            checkboxItems: checkboxItems,
            ["formData.checkbox"]: e.detail.value,
        });
    },
});